# 使用 Thread 子类创建线程

import threading, time, os


class SubThread(threading.Thread):

    def run(self):
        for i in range(2):
            time.sleep(1.5)
            print("线程的名字：", threading.current_thread().getName(), "变量：", i)


if __name__ == "__main__":
    print("主进程开始， pid:", os.getpid())
    t1 = SubThread()
    t2 = SubThread()
    t1.start()
    t2.start()

    print("主进程结束， pid:", os.getpid())
    time.sleep(100)  # 防止主进程过早退出
